pandas 1.4.2

ParametersReturns
cumprod(self, axis=None, skipna=True, *args, **kwargs)

Returns a DataFrame or Series of the same size containing the cumulative product.

Parameters

axis : {0 or 'index', 1 or 'columns'}, default 0

The index or the name of the axis. 0 is equivalent to None or 'index'.

skipna : bool, default True

Exclude NA/null values. If an entire row/column is NA, the result will be NA.

*args, **kwargs :

Additional keywords have no effect but might be accepted for compatibility with NumPy.

Returns

scalar or Series

Return cumulative product of scalar or Series.

Return cumulative product over a DataFrame or Series axis.

See Also

Series.cummax

Return cumulative maximum over Series axis.

Series.cummin

Return cumulative minimum over Series axis.

Series.cumprod

Return cumulative product over Series axis.

Series.cumsum

Return cumulative sum over Series axis.

Series.prod

Return the product over Series axis.

core.window.Expanding.prod

Similar functionality but ignores NaN values.

Examples

Series

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series([2, np.nan, 5, -1, 0])
... s 0 2.0 1 NaN 2 5.0 3 -1.0 4 0.0 dtype: float64

By default, NA values are ignored.

This example is valid syntax, but we were not able to check execution
>>> s.cumprod()
0     2.0
1     NaN
2    10.0
3   -10.0
4    -0.0
dtype: float64

To include NA values in the operation, use skipna=False

This example is valid syntax, but we were not able to check execution
>>> s.cumprod(skipna=False)
0    2.0
1    NaN
2    NaN
3    NaN
4    NaN
dtype: float64

DataFrame

This example is valid syntax, but we were not able to check execution
>>> df = pd.DataFrame([[2.0, 1.0],
...  [3.0, np.nan],
...  [1.0, 0.0]],
...  columns=list('AB'))
... df A B 0 2.0 1.0 1 3.0 NaN 2 1.0 0.0

By default, iterates over rows and finds the product in each column. This is equivalent to axis=None or axis='index' .

This example is valid syntax, but we were not able to check execution
>>> df.cumprod()
     A    B
0  2.0  1.0
1  6.0  NaN
2  6.0  0.0

To iterate over columns and find the product in each row, use axis=1

This example is valid syntax, but we were not able to check execution
>>> df.cumprod(axis=1)
     A    B
0  2.0  2.0
1  3.0  NaN
2  1.0  0.0
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/generic.py#11033
type: <class 'function'>
Commit: